<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>成库核查</title>
        <link rel="stylesheet" type="text/css" href="/webapp/css/easyui.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/icon.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/color.css">
        <link rel="stylesheet" type="text/css" href="/webapp/css/public.css">
        <script type="text/javascript" src="/webapp/js/lib/jquery.min.js"></script>
        <script type="text/javascript" src="/webapp/js/lib/jquery.easyui.min.js"></script>
        <script type="text/javascript" src="/webapp/js/lib/jquery.global.settings.js"></script>
        <script type="text/javascript" src="/webapp/js/common/config.js"></script>
    </head>
    <body>
        <div class="easyui-container-fluid">
            <div class="easyui-panel" style="border: none;">
                <div class="nav" id="nav"></div>
                <div class="easyui-panel" style="border:none;">
                    <form id="ff" method="post">
                        <div style="margin-bottom: 20px;">
                            <label class="item-label">年：</label>
                            <input type="text" id="year" name="year" class="easyui-combobox" data-options="required:true" required="required" style="width: 100px;"/>
                            <span id="monthLabel">
                        <label class="item-label">月：</label>
                        <input type="text" id="month" name="month" class="easyui-combobox" data-options="required:true" required="required" style="width: 100px;">
                        </span>
                            <span id="weekLabel">
                        <label class="item-label">周：</label>
                        <input type="text" id="week" name="week" class="easyui-combobox" data-options="required:true" required="required" style="width: 100px;">
                            </span>
                            <a href="javascript:void(0);" class="easyui-linkbutton c8" onclick="searchBy()" style="width:80px;margin-left: 40px;">查询</a>
                        </div>
                    </form>
                </div>
                <div class="table-wrapper">
                    <table id="datagrid" style="height: 715px" data-options="singleSelect:true,fitColumns:true,scrollbarSize:0,checkOnSelect:false">
                        <thead>
                            <tr>
                                <th data-options="field:'category',align:'center'" width="40">品类</th>
                                <th data-options="field:'workCount',align:'center'" width="40">工作台(量)</th>
                                <th data-options="field:'workTotal',align:'center'" width="40">工作台(额)</th>
                                <th data-options="field:'statisCount',align:'center'" width="40">统计(量)</th>
                                <th data-options="field:'statisTotal',align:'center'" width="40">统计(额)</th>
                                <th data-options="field:'statisTs',align:'center'" width="40">mongo(条数)</th>
                                <th data-options="field:'ssalesTs',align:'center'" width="40">server(条数)</th>
                                <th data-options="field:'mmodelTs',align:'center'" width="40">mongo(型号条数)</th>
                                <th data-options="field:'smodelTs',align:'center'" width="40">server(型号条数)</th>
                                <th data-options="field:'errorCount',align:'center',formatter:fontColor"  width="40">异常量</th>
                                <th data-options="field:'errorTotal',align:'center',formatter:fontColor"  width="8%">异常额</th>
                                <th data-options="field:'errorTs',align:'center',formatter:fontColor"  width="8%">异常条</th>
                                <th data-options="field:'isPass',align:'center',formatter:isPassF" width="8%">核对状态</th>
                                <!--<th data-options="field:'action',formatter:actions,align:'center'" width="330">操作</th>-->
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </body>
    <script>
        $(function () {
            setNav();
            $("#datagrid").datagrid({
                pagination: true,
                rownumbers: true,
                checkOnSelect: false
            }).datagrid("getPager").pagination({
                onSelectPage: searchBy
            });
            $.when(initMonthWeek("monthLabel", "weekLabel")).done(function () {
                searchBy(1, 100);
            });
            aRecords("成库核查","/webapp/pages/check/statisticsCheck")
        });

        function searchBy(page, size) {
            var data = getFormData(document.getElementById("ff"));
            data['page'] = page || 1;
            data['size'] = size || 100;
            data['reportType'] = window.parent.workMode.toUpperCase();
            $.ajax({
                url: config.url + "/statisticsCheck/getData",
                type: "get",
                data: transfer(data),
                dataType: "json",
                xhrFields: {withCredentials: true},
                beforeSend: function () {
                    $.messager.progress({
                        title: "请稍等",
                        interval: 50,
                        text: "数据加载中..."
                    });
                },
                complete: function () {
                    $.messager.progress("close");
                },
                success: function (data) {
                    $.messager.progress("close");
                    if (data.msg) {
                        $("#datagrid").datagrid("loadData", data.msg);
                    }
                },
                error: function (data) {
                    $.messager.progress("close");
                    console.log(data);
                }
            });
        }
        function statisticsStatusFormatter(val, row) {
            var ss = "";
            switch (val) {
                case "WAREHOUSE":
                    ss = "成库";
                    break;
                case "TRANSFER":
                    ss = "转移数据";
                    break;
                case "GENERATE":
                    ss = "生成报告";
                    break;
                case "GENERATING":
                    ss = "报告生成中";
                    break;
                case "DOWNLOAD":
                    ss = "下载报告";
                    break;
            }
            return ss;
        }

        function sinkStatusFormatter(val, row) {
            var value = "";
            switch (val) {
                case "WAITING":
                    value = "等待中";
                    break;
                case "STATISTICS":
                    value = "统计中";
                    break;
                case "RUNNING":
                    value = "同步中";
                    break;
                case "COMBO_RUNNING":
                    value = "套餐同步中";
                    break;
                case "UNCOMBO_RUNNING":
                    value = "非套餐同步中";
                    break;
                case "STA_FAIL":
                    value = "统计失败";
                    break;
                case "SYN_FAIL":
                    value = "同步失败";
                    break;
                case "VISIT_FAIL":
                    value = "访问失败";
                    break;
                case "SUCCESS":
                    value = "完成";
                    break;
                case "STA_SUCCESS":
                    value = "统计完成";
                    break;
            }
            return value;
        }

        function isPassF(val, row) {
            if(val){
                return "<a class='l-btn-left l-btn-icon-left' style='width:24px;height:24px;'><span class='l-btn-icon icon-ok'></span></a>";
            }else{
                return "<a class='l-btn-left l-btn-icon-left' style='width:24px;height:24px;'><span class='l-btn-icon icon-no'></span></a>";
            }
        }

        function fontColor(val, row) {
            if (val&&val<0) {
                return '<span style="font-size: 14px;font-weight: bold;color: red;">' + val + '</span>';
            }else if(val){
                return '<span style="font-size: 14px;font-weight: bold;color: green;">' + val + '</span>';
            }
        }
    </script>
</html>